<?php
namespace app\test\controller;
use app\common\Rsa;

class Demo{
    public function index(){
        $data['name'] = 'hello';
        $data['age']  = '20';
        $privEncrypt = Rsa::privEncrypt(json_encode($data));
        echo '私钥加密后:'.$privEncrypt.'<br>';

        $publicDecrypt = Rsa::publicDecrypt($privEncrypt);
        echo '公钥解密后:'.$publicDecrypt.'<br>';

        $publicEncrypt = Rsa::publicEncrypt(json_encode($data));
        echo '公钥加密后:'.$publicEncrypt.'<br>';

        $privDecrypt = Rsa::privDecrypt($publicEncrypt);
        echo '私钥解密后:'.$privDecrypt.'<br>';
    }
}